﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DXApplicationTangche.UC.订单一览新.对账.Service;

namespace DXApplicationTangche.UC.订单一览新.对账
{
    public partial class Form保存销售订单支付方式 : DevExpress.XtraEditors.XtraForm
    {
        private List<SalePaymentDetailDTO> salePaymentDetailDTOs = new List<SalePaymentDetailDTO>();
        public Form保存销售订单支付方式(List<SalePaymentDetailDTO> salePaymentDetailDTOs)
        {
            InitializeComponent();
            this.salePaymentDetailDTOs = salePaymentDetailDTOs;
            this.gridControl待确认支付方式一览.DataSource = this.salePaymentDetailDTOs;
            this.gridView待确认支付方式一览.RefreshData();
            this.gridView待确认支付方式一览.BestFitColumns();
        }

        private void simpleButton保存_Click(object sender, EventArgs e)
        {
            if (this.salePaymentDetailDTOs.Count <= 0)
            {
                MessageBox.Show("无确认内容");
                return;
            }
            if (String.IsNullOrWhiteSpace(this.comboBox支付方式.Text))
            {
                MessageBox.Show("请选择支付方式");
                return;
            }
            List<String> saleConfirmIds = new List<String>();
            foreach (SalePaymentDetailDTO item in this.salePaymentDetailDTOs)
            {
                saleConfirmIds.Add(item.id);
            }
            对账Service.savePaymentType(this.comboBox支付方式.SelectedItem.ToString(), saleConfirmIds);
            this.Close();
        }
    }
}